<?php

class OptionsGeneralController extends Controller {
    var $name = 'OptionsGeneral';
    var $uses = array('Options');
    var $components = array('options', 'language');

    function index() {
        $this->action = 'options_general';
        $this->options_general();
    }

    function options_general($status = null) {
        if (!empty($this->data['Options'])) {
            foreach($this->data['Options'] as $key => $value) {
                update_option($key, $value);
            }

            $this->redirect('/options_general/options_general/update_done');
            exit();
        }
        $options = $this->Options->find_all('',array('option_name', 'option_value'));
        foreach($options as $option) {
            $this->data['Options'][$option->option_name] = $option->option_value;
        }
        if ($status == 'update_done') {
            $this->header_notice = __('Options saved.');
        }
        $languages = get_languages();
        $this->set('language_options', $languages);
        # set the example time format
        $this->set('time_example', time_format(time()));
    }
}

?>
